//
// Created by z on 2021/3/25.
//
#include <string>
#include "Input.h"
#include "Parser.h"
#include <cassert>
#include "Output.h"
#include "ServerInstance.h"

using namespace std;
using namespace hw;

namespace {
    void test_parser() {
        string s = "(host0Y6DP, 300, 830, 141730, 176)";
        ServerType&& serverType = Parser::parse_server(s);
        assert(serverType.core == 300);
        assert(serverType.memory == 830);
        assert(serverType.hardware_price == 141730);
        assert(serverType.daily_cost == 176);

        s = "(vmN9DL5, 118, 6, 1)";
        Vmtype&& vmtype = Parser::parse_vm(s);
        assert(vmtype.core == 118);
        assert(vmtype.memory == 6);
        assert(vmtype.is_double);

        s = "(add, vmBDW56, 322765409)";
        Operation&& op = Parser::parse_operation(s);
        assert(op.mode == Op::ADD);
        assert(op.vm_type_id == "vmBDW56");
        assert(op.vmid == "322765409");

        s = "(del, 729561651)";
        op = Parser::parse_operation(s);
        assert(op.mode == Op::DEL);
        assert(op.vmid == "729561651");

        s = "12 123 1234    12345";
        vector<int> list = Parser::parse_ints(s, ' ');
        assert(list.size() == 4);
        assert(list[0] == 12);
        assert(list[1] == 123);
        assert(list[2] == 1234);
        assert(list[3] == 12345);
    }

    void test_output() {
        Output output(stdout);
        output.purchase_server("whattheheck", 3);
        output.allocate(3);
        output.allocate_single(3, Node::B);
        output.migrate("234143265", 3);
        output.migrate_single("faseoid", 5, Node::A);
    }
}

int
main() {
    test_parser();
    test_output();
    Input input(cin);

    cout<<"Success!"<<endl;
    return 0;
}